<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">app -- {{ msg }}</div>
    <div id="app2">
        <button @click="msg = '你坏'">修改msg</button>
        <p>app2- {{ msg }}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        //el: '#app',
        // template: '<div id="template"><h1>{{ msg }}</h1></div>',
        data () {
          return {
            msg: '你好'
          }
        },
        methods: {
          fn () {
            console.log('fn被调用')
          }
        },
        beforeCreate() {
            console.log('beforeCreate', this.msg) // undefined
        },

        created() {
            console.log('created', this.msg) // 你好
        },

        beforeMount () {
            console.log('beforeMount', document.querySelector('#app2'))
        },

        mounted () {
            console.log('mounted',document.querySelector('#app2'))
        },

        beforeUpdate() {
            console.log('beforeUpdate', this.msg, document.querySelector('p').innerHTML)
        }, 
        updated () {

            console.log('updated', this.msg, document.querySelector('p').innerHTML)
        }

      }).$mount("#app2")
    </script>
  </body>
</html>
